package org.third.fluentd;

import org.fluentd.logger.FluentLogger;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicLong;

public class FluentdMain {

	private static List<FluentLogger> loggers = new ArrayList<FluentLogger>();
	private static final int LOGGER_SIZE = 10;
	private static final String host = "10.30.28.81";
	private static final int port = 24224;
	static {
		for (int i = 0; i < LOGGER_SIZE; i++) {
			loggers.add(FluentLogger.getLogger("fluentd.test" + i, host, port));
		}
	}

	public static void main(String[] args) {
		// ...
		AtomicLong counter = new AtomicLong(100000);
		while (true)
		{
			Map<String, Object> data = new HashMap<String, Object>();
			data.put("id", "ID_"+counter.getAndIncrement());
			data.put("message", "[info]: testmsg_"+counter.get());
			data.put("to", "userB");
			try {
				Thread.sleep(2000);
				loggers.forEach(l -> {
					l.log("follow", data);
				});
			} catch (Exception e) {
			}
		}
	}
}
